package com.db.router.context;

public enum RouterStrategy {

    /**
     * 哈希
     */
    HASH("DBRouterStrategyHash","hash"),
    /**
     * 一致性哈希
     */
    CONSISTENT_HASH("DBRouterStrategyConsistentHash","ConsistentHash");


    private final String strategyBeanName;
    private final String strategyName;

    private RouterStrategy(String strategyAliasName, String strategyName){
        this.strategyBeanName = strategyAliasName;
        this.strategyName = strategyName;
    }

    public String getStrategyBeanName(){
        return this.strategyBeanName;
    }

    public String getStrategyName(){
        return this.strategyName;
    }

    public static RouterStrategy getEnumByStrategyName(String strategyName){
        for (RouterStrategy value : values()) {
            if(value.strategyName.equals(strategyName)){
                return value;
            }
        }
        return HASH;
    }
}
